import axios from 'axios'
import querystring from 'querystring'

//请求拦截
axios.interceptors.request.use(req=>{
    return req
})

axios.interceptors.response.use(res=>{
    return res
})

export function get(url,params={}){
    return axios({
        url,
        method:'get',
        params
    })
}

export function post(url,params={},isFile=false){
    let data = null 
    if(isFile){
        data = new FormData()
        for(let i in params){
            data.append(i,params[i])
        }
    }else{
        data  = querystring.stringify(params)
    }

    return axios({
        url,
        method:'post',
        data
    })
}